﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Pharmacy.Web.UI;
using Pharmacy.Entities;
using Pharmacy.Data;
using Pharmacy.Settings.BusinessLayer;

public partial class Admin_AdjustmentEdit : System.Web.UI.Page
{
    string AdjustmentId = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            WhereClauseHiddenField.Value = GetWhereClause();
        }
        FormUtil.RedirectAfterInsertUpdate(FormView1, "AdjustmentEdit.aspx?{0}", AdjustmentDataSource);
        FormUtil.RedirectAfterAddNew(FormView1, "AdjustmentEdit.aspx");
        FormUtil.RedirectAfterCancel(FormView1, "Adjustment.aspx");
        FormUtil.SetDefaultMode(FormView1, "AdjustmentId");

        FormUtil.SetPageIndex(GridView1, "page");
        FormUtil.SetDefaultButton((Button)GridViewSearchPanel1.FindControl("cmdSearch"));
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string urlParams = string.Format("AdjustmentId={0}", GridView1.SelectedDataKey.Values[0]);
        Response.Redirect("AdjustmentEdit.aspx?" + urlParams, true);
    }

    protected string GetWhereClause()
    {
        AdjustmentId = Request.QueryString["AdjustmentId"];
        string WhereClause = "AdjustmentId = '" + AdjustmentId + "'";
        return WhereClause;
    }

    protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        if (e.CommandName == "Preview")
        {
            string AdjustmentId = Request.QueryString["AdjustmentId"].ToString();
            Response.Redirect("PreviewAdjustment.aspx?AdjustmentId=" + AdjustmentId);
        }
    }
}
